import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '策略编号',
    align:"center",
    dataIndex: 'policyId'
   },
   {
    title: '策略名称',
    align:"center",
    dataIndex: 'policyName'
   },
   {
    title: '策略描述',
    align:"center",
    dataIndex: 'policyDescription'
   },
   {
    title: '策略类型',
    align:"center",
    dataIndex: 'policyType'
   },
   {
    title: '创建人',
    align:"center",
    dataIndex: 'createBy'
   },
   {
    title: '创建时间',
    align:"center",
    sorter: true,
    dataIndex: 'createTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '修改人',
    align:"center",
    dataIndex: 'updateBy'
   },
   {
    title: '修改时间',
    align:"center",
    sorter: true,
    dataIndex: 'updateTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "策略编号",
      field: 'policyId',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "策略名称",
      field: 'policyName',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "策略描述",
      field: 'policyDescription',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "策略类型",
      field: 'policyType',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "创建人",
      field: 'createBy',
      component: 'Input',
      //colProps: {span: 6},
 	},
     {
      label: "创建时间",
      field: "createTime",
      component: 'RangePicker',
      componentProps: {
          valueType: 'Date',
      },
      //colProps: {span: 6},
	},
	{
      label: "修改人",
      field: 'updateBy',
      component: 'Input',
      //colProps: {span: 6},
 	},
     {
      label: "修改时间",
      field: "updateTime",
      component: 'RangePicker',
      componentProps: {
          valueType: 'Date',
      },
      //colProps: {span: 6},
	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '策略编号',
    field: 'policyId',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入策略编号!'},
          ];
     },
  },
  {
    label: '策略名称',
    field: 'policyName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入策略名称!'},
          ];
     },
  },
  {
    label: '策略描述',
    field: 'policyDescription',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入策略描述!'},
          ];
     },
  },
  {
    label: '策略类型',
    field: 'policyType',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入策略类型!'},
          ];
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  policyId: {title: '策略编号',order: 0,view: 'text', type: 'string',},
  policyName: {title: '策略名称',order: 1,view: 'text', type: 'string',},
  policyDescription: {title: '策略描述',order: 2,view: 'textarea', type: 'string',},
  policyType: {title: '策略类型',order: 3,view: 'text', type: 'string',},
  createBy: {title: '创建人',order: 4,view: 'text', type: 'string',},
  createTime: {title: '创建时间',order: 5,view: 'date', type: 'string',},
  updateBy: {title: '修改人',order: 6,view: 'text', type: 'string',},
  updateTime: {title: '修改时间',order: 7,view: 'date', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
